<template>
  <div>
    <header class="header">
      <slot name="header"></slot>
    </header>

    <main class="main">
      <div v-for="(item, index) in data" :key="index">
        <!-- 匿名 - 作用域插槽 -->
        <slot :item :index></slot>
      </div>
    </main>

    <footer class="footer">
      <slot name="footer"></slot>
    </footer>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";

type names = {
  name: string;
  age: number;
};

const data = ref<names[]>([
  {
    name: "Jake1",
    age: 24,
  },
  {
    name: "Jake2",
    age: 25,
  },
  {
    name: "Jake3",
    age: 26,
  },
  {
    name: "Jake4",
    age: 27,
  },
]);
</script>

<style scoped>
.header,
.main,
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
}

.header {
  height: 200px;
  background: red;
  color: #fff;
}

.main {
  display: flex;
  flex-direction: column;
  height: 200px;
  background: blue;
  color: #fff;
}

.footer {
  height: 200px;
  background: green;
  color: #fff;
}
</style>
